﻿using System;
using System.IO;
using System.Net;
using System.Xml;
using System.Text;
using System.Web;

namespace SBPweb.PhotoGallery.Host
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
//            lQuery.Text = HttpContext.Current.Request.Cookies[;
            if (!string.IsNullOrEmpty(Request["source"]))
            {
                Uri xmlPath = new Uri(Request["source"], UriKind.RelativeOrAbsolute);
                string xml = null;
                string s;
                if (xmlPath.IsAbsoluteUri)
                {
                    s = xmlPath.AbsoluteUri;
                }
                else
                {
                    s = string.Format("{0}/{1}", Request.Url.OriginalString.Replace(Request.Url.PathAndQuery, ""), xmlPath);
                }
                WebClient wc = new WebClient();
                wc.Encoding = Encoding.UTF8;
                xml = wc.DownloadString(s).Trim();
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xml);
                gvPhotos.Slides = new Slides(doc);
            }
        }
    }
}
